//
//  SHPStatus.swift
//  weibo
//
//  Created by songhuipan on 16/4/21.
//  Copyright © 2016年 songhuipan. All rights reserved.
//

import UIKit

class SHPStatus: NSObject {
    
    /// 微博创建时间
    var created_at: String?
    /// 微博ID
    var id: Int64 = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    /// 用户模型
    var user: SHPUsers?
    /// 被转发的原微博信息字段
    var retweeted_status: SHPStatus?
    /// 微博配图ID
    var pic_urls:[SHPPic_urls]?
    ///  转发数
    var reposts_count: Int = 0
    /// 评论数
    var comments_count: Int = 0
    /// 表态数
    var attitudes_count: Int = 0

    init(dic:[String:AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dic)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        switch key {
            
        case "user":
            if let v = value as? [String:AnyObject] {
            user = SHPUsers(dic:v)
            }
        case "retweeted_status":
            if let v = value as? [String:AnyObject] {
            retweeted_status = SHPStatus(dic: v)
            }
        case "pic_urls":
//            print(value)
            if let array = value as? [[String:AnyObject]] {
                var tempArray : [SHPPic_urls] = [SHPPic_urls]()
                for dic in array {
                    
                    tempArray.append(SHPPic_urls(dic: dic))
                }
                pic_urls = tempArray
            }
        default :
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
        
    }
    override var description :String {
        
        let keys = ["created_at","source","text","id"]
        
        return dictionaryWithValuesForKeys(keys).description
    }

    


}













